、<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
	font-size: 12px;
}
</style>
</head>
<body class="gray-bg">

	<!-- 隐藏域 -->
	<input type="hidden" value="${replaceId}" id="replaceId"
		name="replaceId" />
	<input type="hidden" value="${busiId}" id="busiId" name="busiId" />
	<input type="hidden" value="${modeId}" id="modeId" name="modeId" />
	<!-- 隐藏域 -->
	<div class="buttonfixed">
		<button type="button" class="btn dpbtn_green" id="print" onclick="print();">打印</button>
	</div>
	<div class="container creditbody">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;风控审核>财务审核一</span>
			<a href="javascript:void(0)"></a>
		</div>
		<div class="ibox-content ibox-con">
			<%@include file="/jsp/common_yw_include.jsp"%>
			<div class="business-manwife">业务进程</div>
			<div class="business-padding" id="">
				<table class="yw-course">
					<thead>
						<tr>
							<th id="added_status1" equal="0" class="splztab bg-grey">按揭日报表</th>
							<th id="dianzi" equal="30" class="splztab bg-grey">申请垫资
							<th id="M_cwshy" equal="50" class="splztab bg-green">财务审核1</th>
							<th id="M_cwshe" equal="200" class="splztab">财务审核2</th>
							<th id="caiwudiankuan" class="splztab">财务垫款</th>
							<th id="" class="splztab">垫款调整A</th>
							<th id="" class="splztab">申请垫款调整Ｂ</th>
							<th id="" class="splztab">垫款调整Ｂ审核</th>
							<th id="" class="splztab">垫款调整Ｂ</th>
							<th id="" class="splztab">财务退款</th>
						</tr>
					</thead>
				</table>
			</div>
		</div>

		<div class="business-manwife">协议资料</div>
		<%@include file="/jsp/xieyi_zi_liao.jsp"%>
		
		<!-- //风险准备金账户信息 -->
		<c:if test="${prepare_account }">
			<%@include file="/jsp/comm_count_infor.jsp"%>
		</c:if>
		
		<div class="business-manwife">申请垫资信息</div>
		<div class="tche-padding">
			<table cellpadding="0" cellspacing="0" border="0" class="infor-table">
				<tr>	
					<td align="right"><label class="control-label np">申请垫资时间：</label>
					</td>
					<td>
						<div class="control-div np" id="ywFundApplyCreated">${ywFundApply.created}</div>
					</td>	
				</tr>
				<tr> 
					<td align="right"><label class="control-label np">预计提车时间：</label>
					</td>
					<td>
						<div class="control-div np">${dateFist}</div>
					</td>
				</tr>
				<tr>	
					<td align="right"><label class="control-label np">信息备注：</label>
					</td>
					<td>
						<div class="control-div np" id="">${ywFundApply.remarks}</div>
					</td>	
				</tr>
			</table>
		</div>
		<div class="business-history" style="border-bottom: none;">
			<ul>
				<li>【历史打款】</li>
				<li>${history }</li>
			</ul>
		</div>
		<div class="business-history">
			<ul>
				<li>【历史退款】</li>
				<li><fmt:formatDate value="${cwRefundCar.timeArrive }" pattern="yyyy/MM/dd hh:mm"/></li>
			</ul>
		</div>
		<div class="business-man">费用明细</div>
		<div class="tche-padding">
			<table cellpadding="0" cellspacing="0" border="0" class="thead-table padding-wangge">
				<thead class="thead-a">
					<tr>
						<th class="warn-red-bold">贷款本金</th>
						<th class="warn-red-bold">签约贷款额</th>
						<c:if test="${!empty fundItems_ }">
							<c:forEach items="${fundItems_ }" var="fundItem_" varStatus="status">
								<th class="warn-red-bold">${fundItem_.name }</th>
							</c:forEach>
						</c:if>
					</tr>
				</thead>
				<tbody class="tbody-a">
					<tr>
						<td><fmt:formatNumber type="number" value="${empty ywBusinessLoan.loanAmount ? 0 : ywBusinessLoan.loanAmount}" pattern="0.00" maxFractionDigits="2" /></td>
						<td><fmt:formatNumber type="number" value="${empty ywBusinessLoan.signLoanAmount ? 0 :  ywBusinessLoan.signLoanAmount}" pattern="0.00" maxFractionDigits="2" /></td>
						<c:if test="${!empty fundItems_ }">
							<c:forEach items="${fundItems_ }" var="fundItem_" varStatus="status">
								<td><fmt:formatNumber type="number" value="${empty fundItem_.feeCount ? 0 : fundItem_.feeCount}" pattern="0.00" maxFractionDigits="2" /></td>
							</c:forEach>
						</c:if>
					</tr>
				</tbody>
			</table>
			<c:choose>
				<c:when test="${!empty fundItems }">
					<ul class="thead-tableul">
						<c:forEach items="${fundItems }" var="cwFundItem"
							varStatus="status">
							<c:if test="${status.index % 7 == 0 }">
								<li>
									<table cellpadding="0" cellspacing="0" border="0"
										class="thead-table">
										<thead class="thead-a">
											<tr>
												<th></th>
												<th>应收</th>
												<th>实收</th>
											</tr>
										</thead>
										<tbody class="tbody-a">
											</c:if>
											<tr>
												<td>${cwFundItem.name }</td>
												<td id="fee_td_${cwFundItem.key }"><fmt:formatNumber
														type="number" value="${cwFundItem.feeCount }"
														pattern="0.00" maxFractionDigits="2" /></td>
												<td id="remit_td_${cwFundItem.key }"><fmt:formatNumber
														type="number" value="${cwFundItem.remitCount }"
														pattern="0.00" maxFractionDigits="2" /></td>
											</tr>
											<c:if test="${status.index % 7 == 6  || status.last}">
										</tbody>
									</table>
								</li>
							</c:if>
						</c:forEach>
					</ul>
				</c:when>
				<c:otherwise>
        			没有收费项目
        		</c:otherwise>
			</c:choose>
			<ul class="thead-tableul">
				<li>
					<table cellpadding="0" cellspacing="0" border="0"
						class="thead-table">
						<thead class="thead-a">
							<tr>
								<th></th>
								<th>应收</th>
								<th>实收</th>
							</tr>
						</thead>
						<tbody class="tbody-a">
							<tr>
								<td class="npb style-red">应收合计</td>
								<td><fmt:formatNumber type="number"
										value="${fundTotal.feeCount }" pattern="0.00"
										maxFractionDigits="2" /></td>
								<td><fmt:formatNumber type="number"
										value="${fundTotal.remitCount }" pattern="0.00"
										maxFractionDigits="2" /></td>
							</tr>
						</tbody>
					</table>
				</li>
			</ul>
		</div>
		<div class="business-manwife">过桥贷</div>
		<div class="tche-padding">
			<table cellpadding="0" cellspacing="0" border="0" class="infor-table">
				<tr>
					<td align="right"><label class="control-label np">资金渠道：</label></td>
					<td class="control-div np">
						<mytag:selectTag id="fund_channel" name="fund_channel" others="class='select-control select-control-tebie' required='required'" map="${fund_channel}" selected=""/>
						<select class="select-control select-control-tebie" id="fund_channel1" name="fund_channel1">
							<option value="${mpas.get('value')}">${mpas.get('name')}</option>
						</select> 
					</td>
					<td align="right"><label class="control-label np">第三方渠道业务状态值：</label></td>
					<td class="control-div np">
						<div class="control-div np" id="zppThirdBusiStatus" name="zppThirdBusiStatus" style="font-weight: bold; color: #FC1515;"></div>
					</td>
					<td align="right"><label class="control-label np">历史退款时间：</label></td>
					<td class="control-div np">
						<div class="control-div np" id="timeArrive" name="timeArrive" style="font-weight: bold; color: #FC1515;"></div>
					</td>
				</tr>
			</table>
		</div>
		<div class="business-manwife">返利信息</div>
		<div class="tche-padding">
			<table cellpadding="0" cellspacing="0" border="0" class="infor-table">
				<tr>
					<td align="right"><label class="control-label np">经销商返利：</label>
					</td>
					<td>
						<div class="control-div np">${ywFees.rebateDealer}</div>
					</td>
					<td align="right"><label class="control-label np">分公司展业费：</label>
					</td>
					<td>
						<div class="control-div np">${ywFees.rebateProvince}</div>
					</td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">区域&业务员展业费：</label>
					</td>
					<td>
						<div class="control-div np">${ywFees.rebateArea}</div>
					</td>
					<td align="right"><label class="control-label np">返利方式：</label>
					</td>
					<td>
						<div class="control-div np">${ywFees.rebateType}</div>
					</td>
				</tr>
			</table>
		</div>

		<div class="business-manwife">财务审核1<c:if test="${isSpecialOrder}" >（<span style="color:#FC1515;">该订单被风控标注为特殊订单，银行先放款财务再打款！</span>）</c:if></div>
		<div class="tche-padding">
			<ul class="zxsearch-ulsd">
				<li class="zxsearch-ulli">信息备注：</li>
				<li class="zxsearch-ullib">
					<input type="hidden" value="${ywFundApply.remarks}" id="text_remarks"/>
					<textarea id="audit_detail"name="audit_detail" rows="" cols="" class="form-control"></textarea>
				</li>
			</ul>
			<div class="cbothbutn">
				<button type="button" class="btn dpbtn_blue"
					onclick="allocation();" id="tjbiaobiao" name="tjbiaobiao">通过</button>
			</div>
		</div>
		<div class="business-manwife">经办信息</div>
		<div class="tche-padding">
			<table cellpadding="0" cellspacing="0" border="0"
				class="buyinfor-table">
				<tr>
					<td align="right"><label class="control-label np">经办人：</label>
					</td>
					<td><input class="form-control" type="text" id="uname"
						name="uname" placeholder="经办人" value="${current_user_key.uname}"
						readonly="readonly" /></td>
					<td align="right"><label class="control-label np">经办时间：</label>
					</td>
					<td><input id="jb_time" name="jb_time" placeholder="经办时间"
						class="form-control" readonly="readonly" /></td>
				</tr>
			</table>
		</div>
	</div>
	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>
	<!-- layerDate plugin javascript -->
	<script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
	<!-- 
 	    作者：程立勇
 	   描述：js脚本
 	 -->
	<script type="text/javascript">
 	
	 	$(function(){
	 		
	 		var date = new Date();
	    	document.getElementById("jb_time").value = date.format("yyyy-MM-dd h:m:s");
	    	
	    	$('#ywFundApplyCreated').text(formateIntegerMinutes($('#ywFundApplyCreated').text()))
	    	initData();
	 	});
	 	
	 	
	 	var thirdBusiStatus = 0;
	 	
	 	//初始化
	 	var initData = function()
	 	{
	 		var text_remarks = $('#text_remarks').val();
	 		$('#audit_detail').val(text_remarks);
	 		var busiId = $('#busiId').val();
	 		$.dpAjax({
 				url:'${basePath}/FengKongShenHeController/diepuCwshyInit',
	 			data:{"busiId":busiId},
	 			success: function(datas)
	 			{
	 				 if(datas.flag == 100100)
	 				 {
	 					 var ywBusiness = datas.ywBusiness;
	 					 if(ywBusiness)
	 					 {
	 						 $('#zppThirdBusiStatus').html(ywBusiness.thirdBusiStatusDisplay);
	 						 $('#timeArrive').html(datas.timeArrive);
	 						 if(ywBusiness.thirdBusiStatus)
	 						 {
	 							 if(ywBusiness.thirdBusiStatus >= 250 && ywBusiness.thirdBusiStatus < 9100)
		 						 {
		 							
		 							 $('#fund_channel1').hide();
		 							 thirdBusiStatus = 2;
		 						 }	
		 						 else
		 						 {
		 							 $('#fund_channel').hide();
		 							 thirdBusiStatus = 1;
		 						 }
	 						 }
	 						 else if(!ywBusiness.thirdBusiStatus)
	 						 {
	 							 $('#fund_channel').hide();
	 							 thirdBusiStatus = 1;
	 						 }
	 					 }
	 				 }
	 		    }
	 		});
	 	}
	 	
	 	
	 	//通过
	 	var allocation = function()
	 	{
	 		var replaceId = $('#replaceId').val();
	 		var busiId = $('#busiId').val();
	 		var modeId = $('#modeId').val();
	 		var audit_detail = $('#audit_detail').val();
	 		var org_code = '${current_user_key.orgId}';
	 		var org_name = '${current_user_key.orgName}';
	 		
	 		//鑫合汇
	 		var busiType = "";
	 		var busiTypeText = "";
	 		if(thirdBusiStatus == 1)
	 		{
	 			busiType = $('#fund_channel1').val();
	 			busiTypeText = $('#fund_channel1').find("option:selected").text();
	 		}
	 		else
	 		{
	 			busiType = $('#fund_channel').val();
	 			busiTypeText = $('#fund_channel').find("option:selected").text();
	 		}
	 		if(busiType == "")
	 		{
	 			layer.msg("请选择资金渠道", {icon: 5});
	 			return;
	 		}
	 		
	 		//询问框
	 		layer.confirm('该客户将以'+busiTypeText+'渠道垫资，是否确定？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
	 		  btn: ['确定','取消'] //按钮
	 		}, function(){
	 			layer.msg('正在进入，请稍后...',{icon: 16,shade: 0.15});
	 			layer.closeAll();
	 			$.dpAjax({
	 				url:'${basePath}/FengKongShenHeController/diepuFengKongShenHeV001',
		 			data:{
		 				"event":"pass",
		 				"id":replaceId,
		 				"busiId":busiId,
		 				"modeId":modeId,
		 				"auditDetail":audit_detail,
		 				"auditPostil":audit_detail,
		 				"orgCode":org_code,
		 				"orgName":org_name,
		 				"remarks":"财务审核一",
		 				"reasonAuditFalse":"",
		 				"reasonAuditFalseName":"",
		 				"busiType":busiType
		 			},
		 			success: function(datas)
		 			{
		 				  if(datas.flag == "100100")
		 				  {
		 					  layer.msg('审核执行成功！', {icon: 6});
		 					  setTimeout(function () {
		 						 window.location.href = "${basePath}/web/fengKongShenHe/fkshCwshyList.jsp";
		 					  }, 3000);
		 					  return;
		 				  }
		 				  if(datas.flag == "100200")
		 				  {
		 					  alert(JSON.stringify(datas));
		 					  return;
		 				  }
		 				  layer.msg(datas.message, {icon: 5});
		 		     }
		 		});
	 			
	 		}, function(){
	 			layer.msg('已取消本次操作！', {icon: 6});
	 		});
	 	}
	 	
	 	function print(){
			var busiId = $('#busiId').val();
	    	$.dpAjax({
	    		url:'${basePath}/CwRemitCarController/print',
	    		type:'POST',
	    		data:{busiId:busiId,check:true},
	    		success:function(datas)	{
	    			//成功响应，说明没有报错，可以下载
	    			location.href='${basePath}/CwRemitCarController/print?busiId='+	busiId;
	    			return;
	    		}
	    	});
		}
	</script>
</body>
</html>
